package com.eig.orderweb.controller;

import com.alipay.api.AlipayApiException;
import com.eig.common.vo.Result;
import com.eig.orderweb.service.OrderPayService;
import com.eig.orderweb.service.PayService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ：
 * @date ：Created in 2022/12/24 22:04
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单支付接口类")
public class OrderPayController {

    @Resource
    private OrderPayService orderPayService;


    @PostMapping("/pay/createWeiXin/{courseId}/{memberId}")
    public Result createWeiXin(@PathVariable String courseId,
                               @PathVariable String memberId) {
        return orderPayService.saveOrder(courseId,memberId);
    }

    @PostMapping("/pay/getPayStatus/{orderNo}")
    public Result getPayStatus(@PathVariable String orderNo){
        return orderPayService.selectStatus(orderNo);
    }
    /** 
     * @create by:  Q大侠
     * @description: 支付宝支付 
     * @create time: 2023/1/5 22:19
      * @param  
     * @return  
     */
    @Resource
    private PayService payService;
    @RequestMapping("/pay/allPay/{courseId}/{HuiYuanId}")
    public Result allpay(@PathVariable String courseId,
                         @PathVariable String HuiYuanId) throws AlipayApiException{
            return payService.aliPay(courseId,HuiYuanId);
    }

}
